Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CODENVY-560 : new types of docker recipes, remove InstanceKey, rework InstanceProvider #1366

Merged
merged 1 commit into from
May 30, 2016

Conversation

benoitf
Copy link
Contributor

@benoitf benoitf commented May 27, 2016

1. new docker recipe type

currently we have type:"dockerfile", location: "http://path-to-recipe"

now we could provide
type:"dockerfile", content: "FROM codenvy/foo\nENV FLORENT=TRUE"

and
type:"image", location : "codenvy/foo"

2. InstanceKey

Up to now, InstanceKey was used to perform snapshot recovery.
But machine source is a way to provide this information.
So remove InstanceKey and replace it by MachineSource (and DockerMachineSource instead of DockerInstanceKey)

InstanceProvider:
void removeInstanceSnapshot(InstanceKey instanceKey)
--> void removeInstanceSnapshot(MachineSource machineSource)

Instance:
InstanceKey saveToSnapshot(String owner)
--> MachineSource saveToSnapshot(String owner)

3. InstanceProvider model

To avoid also that MachineManager "knows" the inner type, the recipe handling is moved to the instance provider implementation
And as the snapshot handling is with MachineSource (included in MachineConfig included in Machine), no need to give extra InstanceKey parameter

Replace two previous methods

Instance createInstance(Recipe recipe,
Machine machine,
LineConsumer creationLogsOutput)

Instance createInstance(InstanceKey instanceKey,
Machine machine,
LineConsumer creationLogsOutput) throws NotFoundException, InvalidInstanceSnapshotException, MachineException;

by only one:
createInstance(Machine machine,
LineConsumer creationLogsOutput)

Change-Id: Ia7ea97bc1a44059b4892f5db387f54f2e1709fa3
Signed-off-by: Florent BENOIT fbenoit@codenvy.com

@gazarenkov
Copy link
Contributor

ok with me

@skabashnyuk @garagatyi ?

@garagatyi
Copy link

This PR can't be merged, please rebase

* Alternate way is to provide a location
* @param content the content instead of an external link like with location
*/
void setContent(String content);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use setters in model interfaces

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@codenvy-ci
Copy link

Build # 728 - FAILED

Please check console output at http://ci.codenvy-dev.com/jenkins/job/che-pullrequests-build/728/ to view the results.

@codenvy-ci
Copy link

Build # 742 - FAILED

Please check console output at http://ci.codenvy-dev.com/jenkins/job/che-pullrequests-build/742/ to view the results.

machine.getId(),
userName,
machine.getConfig().getName());
protected Instance doCreateInstanceImage(final Machine machine, String machineContainerName,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method returns Instance which is representation of the container. Please rename this method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's creating instance for type image si method name is accurate

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks to me as create instance of image instead of create instance from image. But if you don't want to change then ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createInstanceFromImage() ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx

@benoitf
Copy link
Contributor Author

benoitf commented May 29, 2016

are we good now ?

if (registry == null || repository == null) {
LOG.error("Failed to remove instance snapshot: invalid instance key: {}", instanceKey);
LOG.error("Failed to remove instance snapshot: invalid instance key: {}", dockerMachineSource);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not instance key anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

* it's based on optional registry followed by repository name followed by a digest or a tag
* Examples are available in the test.
*/
public static final Pattern IMAGE_PATTERN = Pattern.compile("^((?<registry>[^/]++)(?:\\/))?(?<repository>.*?)((?:\\:)(?<tag>.*?))?((?:@)(?<digest>.*))?$");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can see this regexp is not tested. Please review your tests.
Also it looks like
user/repo will be treated as registry user and repository repo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a current class DockerMachineSourceTest with REGEXP being tested by constructor calls
Also now it's delegating to DockerMachineIdentifierParser

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx

@garagatyi
Copy link

LGTM

* Converts {@link MachineSource} to {@link MachineSourceDto}.
*/
public MachineSourceDto asDto(MachineSource source) {
return this.dtoFactory.createDto(MachineSourceDto.class).withType(source.getType()).withLocation(source.getLocation()).withContent(source.getContent());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrap lines? Would it be more readable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@skabashnyuk
Copy link
Contributor

ok

…ove InstanceKey

#1 new docker recipe type

currently we have type:"dockerfile", location: "http://path-to-recipe"

now we could provide
type:"dockerfile", content: "FROM codenvy/foo\nENV FLORENT=TRUE\"

and
type:"image", location or content: "codenvy/foo"

#2 InstanceKey
Up to now, InstanceKey was used to perform snapshot recovery.
But machine source is a way to provide this information.
So remove InstanceKey and replace it by MachineSource (and DockerMachineSource instead of DockerInstanceKey)

InstanceProvider:
void removeInstanceSnapshot(InstanceKey instanceKey)
--> void removeInstanceSnapshot(MachineSource machineSource)

Instance:
InstanceKey saveToSnapshot(String owner)
--> MachineSource saveToSnapshot(String owner)

#3 InstanceProvider model
To avoid also that MachineManager "knows" the inner type, the recipe handling is moved to the instance provider implementation
And as the snapshot handling is with MachineSource (included in MachineConfig included in Machine), no need to give extra InstanceKey parameter

Replace two previous methods

Instance createInstance(Recipe recipe,
                            Machine machine,
                            LineConsumer creationLogsOutput)

 Instance createInstance(InstanceKey instanceKey,
                            Machine machine,
                            LineConsumer creationLogsOutput) throws NotFoundException, InvalidInstanceSnapshotException, MachineException;

by only one:
   createInstance(Machine machine,
                            LineConsumer creationLogsOutput)

Change-Id: Ia7ea97bc1a44059b4892f5db387f54f2e1709fa3
Signed-off-by: Florent BENOIT <fbenoit@codenvy.com>
@benoitf benoitf merged commit ae4c552 into master May 30, 2016
@benoitf benoitf deleted the CODENVY-560 branch May 30, 2016 13:54
@codenvy-ci
Copy link

Build # 752 - FAILED

Please check console output at http://ci.codenvy-dev.com/jenkins/job/che-pullrequests-build/752/ to view the results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants